package cx.ath.skyflyer.gpslog.nmea;


import j2meunit.framework.*;

/**
 * @author lego
 */
public class GeographicPositionTest extends TestCase {
    
    public GeographicPositionTest() {
    }

    private GeographicPositionTest(String name, TestMethod method) {
        super(name, method);
    }

    private GeographicPosition sentence = null;

    public void setUp() {
        try {
            sentence = new GeographicPosition("$GPGLL,8960.0000,N,00000.0000,E,223030.626,V,N*44");
        }
        catch (Exception ex) {
            fail("Setting up failed.");
        }
    }

    public void tearDown() {
    }

    /**
     * Test of testGetLongitude method, of class GeographicPosition.
     */
    public void testGetLongitude() {
        System.out.println("getLongitude");
        String expResult = "00000.0000";
        String result = sentence.getLongitude();
        assertEquals(expResult, result);
        assertTrue(sentence.isEast());
    }

    /**
     * Test of testToString method, of class GeographicPosition.
     */
    public void testToString() {
        try {
            System.out.println("toString");
            final String input = "$GPGLL,8960.0000,N,00000.0000,E,223040.626,V,N*43";
            GeographicPosition instance = new GeographicPosition(input);
            String expResult = input;
            String result = instance.toString();
            assertEquals(expResult, result);
        }
        catch (Exception ex) {
            fail("Shoult not have thrown.");
        }
    }

    /**
     * Test of testGetLatitude method, of class GeographicPosition.
     */
    public void testGetLatitude() {
        System.out.println("getLatitude");
        String expResult = "8960.0000";
        String result = sentence.getLatitude();
        assertEquals(expResult, result);
        assertTrue(sentence.isNorth());
    }

    /**
     * Test of testGetTime method, of class GeographicPosition.
     */
    public void testGetTime() {
        System.out.println("getTime");
        String expResult_1 = "223030.626";
        String result_1 = sentence.getTime();
        assertEquals(expResult_1, result_1);
    }

    public Test suite() {
		TestSuite suite = new TestSuite();

		suite.addTest(new GeographicPositionTest("testGetLongitude", new TestMethod() {
            public void run(TestCase tc) {
                ((GeographicPositionTest)tc).testGetLongitude();
            }
        }));

		suite.addTest(new GeographicPositionTest("testGetLatitude", new TestMethod() {
            public void run(TestCase tc) {
                ((GeographicPositionTest) tc).testGetLatitude();
            }
        }));

		suite.addTest(new GeographicPositionTest("testGetTime", new TestMethod() {
            public void run(TestCase tc) {
                ((GeographicPositionTest) tc).testGetTime();
            }
        }));

		suite.addTest(new GeographicPositionTest("testToString", new TestMethod() {
            public void run(TestCase tc) {
                ((GeographicPositionTest) tc).testToString();
            }
        }));

        return suite;
    }
}
